package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.dao.GeConNewsDao;
import com.htgd.gardenexpo.entity.GeConNews;
import com.htgd.gardenexpo.entity.PageQuery;
import com.htgd.gardenexpo.service.GeConNewsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 新闻表(GeConNews)表服务实现类
 *
 * @author makejava
 * @since 2021-05-31 13:56:18
 */
@Service("geConNewsService")
public class GeConNewsServiceImpl implements GeConNewsService {

    @Resource
    private GeConNewsDao geConNewsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param newId 主键
     * @return 实例对象
     */
    @Override
    public GeConNews queryById(Integer newId) {
        return this.geConNewsDao.queryById(newId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GeConNews> queryAllByLimit(int offset, int limit) {
        return this.geConNewsDao.queryAllByLimit(offset, limit);
    }
    @Override
    public List<GeConNews> queryAllByLimit1(List<Integer> ids,int offset, int limit) {
        return this.geConNewsDao.queryAllByLimit1(ids,offset, limit);
    }
    @Override
    public List<GeConNews> getAllNewsByValue(PageQuery pageQuery)  {
        return this.geConNewsDao.getAllNewsByValue(pageQuery);
    }
    @Override
    public List<GeConNews> getAllNewsByValueNoContent(PageQuery pageQuery)  {
        return this.geConNewsDao.getAllNewsByValueNoContent(pageQuery);
    }

    @Override
    public List<GeConNews> getAllHomeNews() {
        return this.geConNewsDao.getAllHomeNews();
    }

    /**
     * 新增数据
     *
     * @param geConNews 实例对象
     * @return 实例对象
     */
    @Override
    public GeConNews insert(GeConNews geConNews) {
        this.geConNewsDao.insert(geConNews);
        return geConNews;
    }

    /**
     * 修改数据
     *
     * @param geConNews 实例对象
     * @return 实例对象
     */
    @Override
    public GeConNews update(GeConNews geConNews) {
        this.geConNewsDao.update(geConNews);
        return this.queryById(geConNews.getNewId());
    }

    /**
     * 通过主键删除数据
     *
     * @param newId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer newId) {
        return this.geConNewsDao.deleteById(newId) > 0;
    }
}
